<template>
  <div class="home">
    <p>
      <i class="el-icon-s-promotion"></i>
      婚纱摄影
    </p>
    <el-card class="page-wrap">
      <el-table :data="listData">
        <el-table-column width="180px" label="图片">
          <template v-slot="{ row }">
            <img :src="aa+row.pimg" alt="" class="picture"/>
          </template>
        </el-table-column>
        <el-table-column label="店名" prop="pname"></el-table-column>
        <el-table-column label="场地" prop="pscene"></el-table-column>
        <el-table-column label="价格" prop="pprice"></el-table-column>
        <el-table-column label="电话" prop="ptel"></el-table-column>
        <el-table-column label="地址" prop="paddress"></el-table-column>
        <el-table-column label="操作" type="pintroduce" width="120px">
          <template v-slot="{ row }">
            <el-button type="primary" size="small" @click="show(row)">添加购物车</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-row type="flex" justify="center" style="margin-top: 30px">
        <el-pagination
          background
          :total="total"
          layout="prev, pager, next"
          :page-size="size"
          @current-change="currentChange"
        >
        </el-pagination>
      </el-row>
    </el-card>
  </div>
</template>

<script>
import Request from "../api/request";

export default {
  data() {
    return {
      aa: 'data:image/png;base64,',
      listData: [],
      currentPage: '1',
      size: '2',

      total: 0,
    };
  },
  created() {
    this.getList();
  },
  methods: {
    add(id) {
      Request.post()


    },
    getList() {
      Request.get(
        "/photograph/u?current=" + this.currentPage +
        "&size=" + this.size)
        .then(res => {
          this.loading = false

          this.listData = res.data.data.records
          // 分页赋值
          this.currentPage = res.data.data.current
          this.size = res.data.data.size
          this.total = res.data.data.total

        })
    },
    currentChange(page) {
      this.currentPage = page
      this.getList();
    },
    show(row) {

      Request.post("car?id=" + row.photographId + "&type=3").then(res => {


        if (res.data.data) {
          // this.select();
          this.$message({
            duration:1000,
            type: 'success',
            message: '保存成功！'
          })
        } else {
          this.$message({
            duration:1000,
            type: 'info',
            message: ''
          })
        }


      })
    },
  },
};
</script>

<style lang="less" scoped>
.home {
  width: 60%;
  height: 800px;
  margin: 20px auto;

  p {
    color: #fba320;

    i {
      font-size: 24px;
    }
  }
}

.page-wrap {
  margin-top: 30px;
  /* height: 600px; */
}

.picture {
  width: 180px;
  height: 180px;
}
</style>
